package top.xana.acg.anime.network.interceptor

import okhttp3.Headers
import okhttp3.Interceptor
import okhttp3.Response
import timber.log.Timber

/**
 * @author xana
 * @date 2022/8/13 0013 16:53
 * @email cv4096@qq.com
 **/

open class HttpRequestInterceptor : Interceptor {
    companion object {
        const val TAG = "HttpRequestInterceptor"
    }

    override fun intercept(chain: Interceptor.Chain): Response {
        val originalRequest = chain.request()
        val request = originalRequest
            .newBuilder()
            .url(originalRequest.url)
            .headers(Headers.headersOf(
                "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36",
                "Content-Type", "application/json",
                "Accept", "*/*",
                "Cookie", "_ga=GA1.1.377581665.1623328055; JSESSIONID=EC34114081B1A82D58DBA3A93BCCB779; Avatar=https://avatars.githubusercontent.com/u/59495544?v=4; hello-blog-token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ7XCJpZFwiOjMsXCJuYW1lXCI6XCJtaWt1eGFuYVwifSIsImV4cCI6MTY1NzE2MDIzM30.-TlGmahiA_2zILgxy1-KKn4AGWr_ALk01LBz9Q8Ba1I; NMTID=00OiSALuLM3fYgtLUPFnXngbHzdwNwAAAGEA5Pz6A; __remember_me=true; MUSIC_U=4d1c6370e1c69fbc278ecac5aa893e275f78183878bee4c485a66c5a362eaaa2877126f9676d6f8cf23006b5d21d3de92eeec63304de6a1ae2e53b1ffbf10c042f2172e7d5298ce286c18b7af633e86b; __csrf=d20816ad2d65eb21c4b88b91e0adfacd"
            ))
            .build()
        Timber.d(request.toString())
        return chain.proceed(request)
    }
}